package com.wmyg.antifake.config;

import com.wmyg.antifake.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("loginb");
        registry.addViewController("/loginb.html").setViewName("loginb");
        registry.addViewController("/index").setViewName("loginb");
    }


    /**
     * @param  addPathPatterns配置拦截路径
     * @param  excludePathPatterns配置所有请求默认不拦截
     * */

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/factoryDevice/**")
                .addPathPatterns("/user/**")
                .addPathPatterns("/identify/**")
                .addPathPatterns("/product/**")
                .addPathPatterns("/qrcode/**")
                .excludePathPatterns("/");
    }
}
